﻿<template>
  <div>
    <a-card :bordered="false" :bodyStyle="tstyle">

      <div class="table-page-search-wrapper" v-if="hasPerm('NitfAmpHos002:page')">
        <a-form layout="inline">
          <a-row :gutter="48">
            <a-col :md="8" :sm="24">
              <a-form-item label="PSN_NO ">
                <a-input v-model="queryParam.psnNo" allow-clear placeholder="请输入PSN_NO "/>
              </a-form-item>
            </a-col>
            <a-col :md="8" :sm="24">
              <a-form-item label="陕西医保移动支付系统跟踪号区域平台交易跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 ">
                <a-input v-model="queryParam.ampTraceId" allow-clear placeholder="请输入陕西医保移动支付系统跟踪号区域平台交易跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 "/>
              </a-form-item>
            </a-col><template v-if="advanced">
              <a-col :md="8" :sm="24">
                <a-form-item label="平台结算跟踪号平台结算跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 ">
                  <a-input v-model="queryParam.traceId" allow-clear placeholder="请输入平台结算跟踪号平台结算跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="机构交易订单号该值与接口ORG_002(查询待结算费用列表与明细) 的返回值org_trace_no一样 ">
                  <a-input v-model="queryParam.orgTraceNo" allow-clear placeholder="请输入机构交易订单号该值与接口ORG_002(查询待结算费用列表与明细) 的返回值org_trace_no一样 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="机构编号(国标医院编码)机构的国家统一编码 ">
                  <a-input v-model="queryParam.orgCode" allow-clear placeholder="请输入机构编号(国标医院编码)机构的国家统一编码 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="分院编号内部机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 ">
                  <a-input v-model="queryParam.subOrgCode" allow-clear placeholder="请输入分院编号内部机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="退款原因 ">
                  <a-input v-model="queryParam.refundReason" allow-clear placeholder="请输入退款原因 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="退款类型如果传02，则只支持全额退款（医保和自费全额进行退款）如果没有传入默认只退自费部分，如果有传入则至此对应类型的退款01 退“线上自费”02 退“医保和线上自费”  ">
                  <a-input v-model="queryParam.refundType" allow-clear placeholder="请输入退款类型如果传02，则只支持全额退款（医保和自费全额进行退款）如果没有传入默认只退自费部分，如果有传入则至此对应类型的退款01 退“线上自费”02 退“医保和线上自费”  "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="外部退款流水号，到时候查询退款结果根据此订单号可以进行查询，每个机构内保证唯一每个机构内保证唯一 ">
                  <a-input v-model="queryParam.outRefundNo" allow-clear placeholder="请输入外部退款流水号，到时候查询退款结果根据此订单号可以进行查询，每个机构内保证唯一每个机构内保证唯一 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="机构退款流水号自行调用机构系统进行退款后机构的退款订单号 ">
                  <a-input v-model="queryParam.orgRefundSn" allow-clear placeholder="请输入机构退款流水号自行调用机构系统进行退款后机构的退款订单号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="平台退款流水号 ">
                  <a-input v-model="queryParam.refundTraceid" allow-clear placeholder="请输入平台退款流水号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="区域平台退款流水号 ">
                  <a-input v-model="queryParam.ampRefundId" allow-clear placeholder="请输入区域平台退款流水号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="支付渠道退款流水号 ">
                  <a-input v-model="queryParam.payChnlRefundSn" allow-clear placeholder="请输入支付渠道退款流水号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="平台缴费单流水号 ">
                  <a-input v-model="queryParam.orgTraceId" allow-clear placeholder="请输入平台缴费单流水号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="支付渠道流水号 ">
                  <a-input v-model="queryParam.payChnlOrdsn" allow-clear placeholder="请输入支付渠道流水号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="省医保平台订单号 ">
                  <a-input v-model="queryParam.payOrdid" allow-clear placeholder="请输入省医保平台订单号 "/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="交易状态SUCCESS 成功FAIL 失败INIT 初始化REFUND 全额退款EXP 系统异常，待核验ING 处理中 ">
                  <a-input v-model="queryParam.tradeStatus" allow-clear placeholder="请输入交易状态SUCCESS 成功FAIL 失败INIT 初始化REFUND 全额退款EXP 系统异常，待核验ING 处理中 "/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="创建时间">
                  <a-date-picker style="width: 100%" placeholder="请选择创建时间" v-model="queryParam.createDateDate" @change="onChangecreateDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="创建者Id">
                  <a-input v-model="queryParam.createUserId" allow-clear placeholder="请输入创建者Id"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="创建者名称">
                  <a-input v-model="queryParam.createUserName" allow-clear placeholder="请输入创建者名称"/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="更新时间">
                  <a-date-picker style="width: 100%" placeholder="请选择更新时间" v-model="queryParam.modifyDateDate" @change="onChangemodifyDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="修改者Id">
                  <a-input v-model="queryParam.modifyUserId" allow-clear placeholder="请输入修改者Id"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="修改者名称">
                  <a-input v-model="queryParam.modifyUserName" allow-clear placeholder="请输入修改者名称"/>
                </a-form-item>
              </a-col><a-col :md="8" :sm="24">
                <a-form-item label="删除时间">
                  <a-date-picker style="width: 100%" placeholder="请选择删除时间" v-model="queryParam.deleteDateDate" @change="onChangedeleteDate"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="删除者ID">
                  <a-input v-model="queryParam.deleteUserId" allow-clear placeholder="请输入删除者ID"/>
                </a-form-item>
              </a-col>
              <a-col :md="8" :sm="24">
                <a-form-item label="删除者姓名">
                  <a-input v-model="queryParam.deleteUserName" allow-clear placeholder="请输入删除者姓名"/>
                </a-form-item>
              </a-col>            </template>

            <a-col :md="8" :sm="24" >
              <span class="table-page-search-submitButtons">
                <a-button type="primary" @click="$refs.table.refresh(true)" >查询</a-button>
                <a-button style="margin-left: 8px" @click="() => queryParam = {}">重置</a-button>
                <a @click="toggleAdvanced" style="margin-left: 8px"> {{ advanced ? '收起' : '展开' }}
                  <a-icon :type="advanced ? 'up' : 'down'"/>
                </a>
              </span>
            </a-col>

          </a-row>
        </a-form>
      </div>
    </a-card>
    <a-card :bordered="false">
      <s-table
        ref="table"
        :columns="columns"
        :data="loadData"
        :alert="true"
        :rowKey="(record) => record.iD"
        :rowSelection="{ selectedRowKeys: selectedRowKeys, onChange: onSelectChange }">
        <template class="table-operator" slot="operator" v-if="hasPerm('NitfAmpHos002:add')" >
          <a-button type="primary" v-if="hasPerm('NitfAmpHos002:add')" icon="plus" @click="$refs.addForm.add()">新增医保退费</a-button>
        </template>
        <span slot="action" slot-scope="text, record">
          <a v-if="hasPerm('NitfAmpHos002:edit')" @click="$refs.editForm.edit(record)">编辑</a>
          <a-divider type="vertical" v-if="hasPerm('NitfAmpHos002:edit') & hasPerm('NitfAmpHos002:delete')"/>
          <a-popconfirm v-if="hasPerm('NitfAmpHos002:delete')" placement="topRight" title="确认删除？" @confirm="() => NitfAmpHos002Delete(record)">
            <a>删除</a>
          </a-popconfirm>
        </span>
      </s-table>
      <add-form ref="addForm" @ok="handleOk" />
      <edit-form ref="editForm" @ok="handleOk" />
    </a-card>
  </div>
</template>
<script>
  import { STable } from '@/components'
  import moment from 'moment'
  import { NitfAmpHos002Page, NitfAmpHos002Delete } from '@/api/modular/main/NitfAmpHos002Manage'
  import addForm from './addForm.vue'
  import editForm from './editForm.vue'
  export default {
    components: {
      STable,
      addForm,
      editForm
    },
    data () {
      return {
        advanced: false, // 高级搜索 展开/关闭
        queryParam: {},
        columns: [
          {
            title: 'PSN_NO ',
            align: 'center',
            dataIndex: 'psnNo'
          },
          {
            title: '陕西医保移动支付系统跟踪号区域平台交易跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 ',
            align: 'center',
            dataIndex: 'ampTraceId'
          },
          {
            title: '平台结算跟踪号平台结算跟踪号，在ORG_003接口会写入给到机构，机构需要进行存储，需要进行线上自费退款时会用到 ',
            align: 'center',
            dataIndex: 'traceId'
          },
          {
            title: '机构交易订单号该值与接口ORG_002(查询待结算费用列表与明细) 的返回值org_trace_no一样 ',
            align: 'center',
            dataIndex: 'orgTraceNo'
          },
          {
            title: '机构编号(国标医院编码)机构的国家统一编码 ',
            align: 'center',
            dataIndex: 'orgCode'
          },
          {
            title: '分院编号内部机构编号，以用来区分分院或者基卫，如果为空则默认为本院该字典需由定点机构提供 ',
            align: 'center',
            dataIndex: 'subOrgCode'
          },
          {
            title: '退款原因 ',
            align: 'center',
            dataIndex: 'refundReason'
          },
          {
            title: '退款类型如果传02，则只支持全额退款（医保和自费全额进行退款）如果没有传入默认只退自费部分，如果有传入则至此对应类型的退款01 退“线上自费”02 退“医保和线上自费”  ',
            align: 'center',
            dataIndex: 'refundType'
          },
          {
            title: '外部退款流水号，到时候查询退款结果根据此订单号可以进行查询，每个机构内保证唯一每个机构内保证唯一 ',
            align: 'center',
            dataIndex: 'outRefundNo'
          },
          {
            title: '机构退款流水号自行调用机构系统进行退款后机构的退款订单号 ',
            align: 'center',
            dataIndex: 'orgRefundSn'
          },
          {
            title: '平台退款流水号 ',
            align: 'center',
            dataIndex: 'refundTraceid'
          },
          {
            title: '区域平台退款流水号 ',
            align: 'center',
            dataIndex: 'ampRefundId'
          },
          {
            title: '支付渠道退款流水号 ',
            align: 'center',
            dataIndex: 'payChnlRefundSn'
          },
          {
            title: '平台缴费单流水号 ',
            align: 'center',
            dataIndex: 'orgTraceId'
          },
          {
            title: '支付渠道流水号 ',
            align: 'center',
            dataIndex: 'payChnlOrdsn'
          },
          {
            title: '省医保平台订单号 ',
            align: 'center',
            dataIndex: 'payOrdid'
          },
          {
            title: '交易状态SUCCESS 成功FAIL 失败INIT 初始化REFUND 全额退款EXP 系统异常，待核验ING 处理中 ',
            align: 'center',
            dataIndex: 'tradeStatus'
          },
          {
            title: '创建时间',
            align: 'center',
            dataIndex: 'createDate'
          },
          {
            title: '创建者Id',
            align: 'center',
            dataIndex: 'createUserId'
          },
          {
            title: '创建者名称',
            align: 'center',
            dataIndex: 'createUserName'
          },
          {
            title: '更新时间',
            align: 'center',
            dataIndex: 'modifyDate'
          },
          {
            title: '修改者Id',
            align: 'center',
            dataIndex: 'modifyUserId'
          },
          {
            title: '修改者名称',
            align: 'center',
            dataIndex: 'modifyUserName'
          },
          {
            title: '删除时间',
            align: 'center',
            dataIndex: 'deleteDate'
          },
          {
            title: '删除者ID',
            align: 'center',
            dataIndex: 'deleteUserId'
          },
          {
            title: '删除者姓名',
            align: 'center',
            dataIndex: 'deleteUserName'
          }
        ],
        tstyle: { 'padding-bottom': '0px', 'margin-bottom': '10px' },
        // 加载数据方法 必须为 Promise 对象
        loadData: parameter => {
          return NitfAmpHos002Page(Object.assign(parameter, this.switchingDate())).then((res) => {
            return res.data
          })
        },
        selectedRowKeys: [],
        selectedRows: []
      }
    },
    created () {
      if (this.hasPerm('NitfAmpHos002:edit') || this.hasPerm('NitfAmpHos002:delete')) {
        this.columns.push({
          title: '操作',
          width: '150px',
          dataIndex: 'action',
          scopedSlots: { customRender: 'action' }
        })
      }
    },
    methods: {
      moment,
      /**
       * 查询参数组装
       */
      switchingDate () {
        const queryParamcreateDate = this.queryParam.createDateDate
        if (queryParamcreateDate != null) {
            this.queryParam.createDate = moment(queryParamcreateDate).format('YYYY-MM-DD')
            if (queryParamcreateDate.length < 1) {
                delete this.queryParam.createDate
            }
        }
        const queryParammodifyDate = this.queryParam.modifyDateDate
        if (queryParammodifyDate != null) {
            this.queryParam.modifyDate = moment(queryParammodifyDate).format('YYYY-MM-DD')
            if (queryParammodifyDate.length < 1) {
                delete this.queryParam.modifyDate
            }
        }
        const queryParamdeleteDate = this.queryParam.deleteDateDate
        if (queryParamdeleteDate != null) {
            this.queryParam.deleteDate = moment(queryParamdeleteDate).format('YYYY-MM-DD')
            if (queryParamdeleteDate.length < 1) {
                delete this.queryParam.deleteDate
            }
        }
        const obj = JSON.parse(JSON.stringify(this.queryParam))
        return obj
      },
      NitfAmpHos002Delete (record) {
        NitfAmpHos002Delete(record).then((res) => {
          if (res.success) {
            this.$message.success('删除成功')
            this.$refs.table.refresh()
          } else {
            this.$message.error('删除失败') // + res.message
          }
        })
      },
      toggleAdvanced () {
        this.advanced = !this.advanced
      },
      onChangecreateDate(date, dateString) {
        this.createDateDateString = dateString
      },
      onChangemodifyDate(date, dateString) {
        this.modifyDateDateString = dateString
      },
      onChangedeleteDate(date, dateString) {
        this.deleteDateDateString = dateString
      },
      handleOk () {
        this.$refs.table.refresh()
      },
      onSelectChange (selectedRowKeys, selectedRows) {
        this.selectedRowKeys = selectedRowKeys
        this.selectedRows = selectedRows
      }
    }
  }
</script>
<style lang="less">
  .table-operator {
    margin-bottom: 18px;
  }
  button {
    margin-right: 8px;
  }
</style>
